import {
  ImageUrl
} from '../../../../utils/imageHelper';
const reqInterface = require("../../../../api/models");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    ImageObj: ImageUrl,
    activeNames: ['1', '2', '3', '4', '5', '6', '7', '8'],

    description: '', // 个人介绍
    id: 0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.getPersonal()
  },

  toEdit(e) {
    let self = this;
    switch (e.currentTarget.dataset.name) {
      case "1":
        self.toLink('/pages/home/job/resume/basic/index');
        break;
      case "2":
        self.toLink('/pages/home/job/resume/contact/index');
        break;
      case "3":
        wx.navigateTo({
          url: '/pages/home/job/resume/introduction/index?id=' + self.data.id
        })
        break;
      case "4":
        wx.navigateTo({
          url: '/pages/home/job/resume/skill/index?id=' + self.data.id
        })
        break;
      case "5":
        wx.navigateTo({
          url: '/pages/home/job/resume/train/index?id=' + self.data.id
        })
        break;
      case "6":
        wx.navigateTo({
          url: '/pages/home/job/resume/intention/index?id=' + self.data.id
        })
        break;
      case "7":
        wx.navigateTo({
          url: '/pages/home/job/resume/experience/index?id=' + self.data.id
        })
        break;
      default:
        wx.navigateTo({
          url: '/pages/home/job/resume/credential/index?id=' + self.data.id
        })
    }
  },

  toLink(path) {
    let self = this;
    wx.navigateTo({
      url: path,
    })
  },

  // 个人介绍
  getPersonal() {
    let self = this;
    reqInterface.GetJobapplicantListintroduction({
      page: 1,
      pagesize: 10,
      sort: 'id',
      sortby: 'asc'
    }).then(res => {
      if (res.jobapplicantintroductions.length > 0) {
        self.setData({
          id: res.jobapplicantintroductions[0].id
        })
        self.getPersonalDetail(res.jobapplicantintroductions[0].id);
      } else {
        self.setData({
          description: '<div>暂未填写个人简介</div>'
        })
      }
    })
  },

  getPersonalDetail(val) {
    let self = this;
    reqInterface.GetJobapplicantIntroductiondetail({
      id: val
    }).then(res => {
      self.setData({
        description: res.description
      })
    })
  }
})